package com.ruoyi.web.controller.nongjt;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.nongjt.service.INjtUserRegisterService;
import com.ruoyi.nongjt.stats.vo.BarPictureVO;
import com.ruoyi.nongjt.stats.vo.PiePictureVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计控制器
 */
@RestController
@RequestMapping("/nongjt/stats")
public class StatController extends BaseController {

    @Autowired
    private INjtUserRegisterService njtUserRegisterService;

    /**
     * 获取饼状图数据 - 会员分布统计
     */
    @GetMapping("/pie/{year}")
    public AjaxResult getPieChartData(@PathVariable Integer year) {
        List<PiePictureVO> pieData = njtUserRegisterService.getMemberDistribution(year);
        return success(pieData);
    }

    /**
     * 获取柱状图数据 - 月度注册趋势
     */
    @GetMapping("/bar/{year}")
    public AjaxResult getBarChartData(@PathVariable Integer year) {
        BarPictureVO barData = njtUserRegisterService.getMonthlyRegistration(year);
        return success(barData);
    }
}